package com.paradogs.gs.misc;

import com.paradogs.common.utils.SpringUtils;
import com.paradogs.framework.server.ServerEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author: yumi
 * @date: 2024/12/20  15:12
 * @Description: TODO
 */
@Component
public class ServiceManager {

    @EventListener(ServerEvent.ServerStartEvent.class)
    public void onServerStart() {
        Map<String, BaseService> services = SpringUtils.getBeans(BaseService.class);
        for (BaseService service : services.values()) {
            service.onStart();
        }
    }

    @EventListener(ServerEvent.ServerUpdateEvent.class)
    public void onServiceUpdate() {
        Map<String, BaseService> services = SpringUtils.getBeans(BaseService.class);
        for (BaseService service : services.values()) {
            service.onUpdate();
        }
    }

}
